package com.cal.utms.entity;

import java.io.Serializable;

import javax.persistence.*;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import java.util.List;

/**
 * The persistent class for the menu_item database table.
 * 
 */
@Entity
@Table(name = "menu_item")
@NamedQuery(name = "MenuItem.findAll", query = "SELECT m FROM MenuItem m")
public class MenuItem implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	private String action;

	private String name;

	@Column(name = "`ORDER`")
	private int order;

	private String status;

	// bi-directional many-to-many association to Menu
	@LazyCollection(LazyCollectionOption.FALSE)
	@ManyToMany(mappedBy = "menuItems")
	private List<Menu> menus;

	// bi-directional many-to-one association to MenuItem
	@ManyToOne
	@JoinColumn(name = "PARENT_ID")
	private MenuItem menuItem;

	// bi-directional many-to-one association to MenuItem
	@OneToMany(fetch = FetchType.EAGER, mappedBy = "menuItem")
	private List<MenuItem> menuItems;

	// bi-directional many-to-one association to Screen
	@ManyToOne
	private Screen screen;

	public MenuItem() {
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getAction() {
		return this.action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getOrder() {
		return this.order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public List<Menu> getMenus() {
		return this.menus;
	}

	public void setMenus(List<Menu> menus) {
		this.menus = menus;
	}

	public MenuItem getMenuItem() {
		return this.menuItem;
	}

	public void setMenuItem(MenuItem menuItem) {
		this.menuItem = menuItem;
	}

	public List<MenuItem> getMenuItems() {
		return this.menuItems;
	}

	public void setMenuItems(List<MenuItem> menuItems) {
		this.menuItems = menuItems;
	}

	public MenuItem addMenuItem(MenuItem menuItem) {
		getMenuItems().add(menuItem);
		menuItem.setMenuItem(this);

		return menuItem;
	}

	public MenuItem removeMenuItem(MenuItem menuItem) {
		getMenuItems().remove(menuItem);
		menuItem.setMenuItem(null);

		return menuItem;
	}

	public Screen getScreen() {
		return this.screen;
	}

	public void setScreen(Screen screen) {
		this.screen = screen;
	}

}